﻿// funtion like product
function likeproduct(ProductId) {
    $.ajax({
        type: "GET",
        url: "ajax/LikeProduct.ashx?ProductID='" + ProductId + "'",
        success: function (responseText) {
            if (responseText == 1) {
                alert("Like success");
            }
            else if (responseText == -1) {
                alert("Like fail");
            }
        }
    });
}
// Function add product to favourite
function FavouriteProduct(ProductId) {
    $.ajax({
        type: "GET",
        url: "ajax/Favourite.ashx?ProductID='" + ProductId + "'",
        success: function (responseText) {
            if (responseText == 1) {
                alert("Add success");
            }
            else if (responseText == -1) {
                alert("Add fail");
            }
        }
    });
}

function AddAdv(element, url) {
    $(element).hover(
        function () {
            if ($(element).find("div").hasClass("advert")==false) {
                var widthElement = $(element).find("img").width();
                var str = "<div class='advert' style='width:" + widthElement + "px'><a href='" + url + "'>Đăng quảng cáo</a></div>";
                $(element).prepend(str);
                $('.advert').css({ 'visibility': 'visible', 'width': +widthElement + 'px', 'opacity': '0.60','z-index':'100' }).show().fadeIn("slow");
            }
        }, function () {
            $(element).find(".advert").css({ 'visibility': 'hidden', 'opacity': '0' }).fadeOut("slow").remove();
        }
    );
    
}
function removeAdv(element) {
    $(element).find(".advert").css({ 'visibility': 'hidden', 'opacity': '0' }).fadeOut("slow").remove();
}